package start.demo01.datatype.datasource;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.util.HashMap;
import java.util.Map;

public class ESPool {
    private Map<String, RestHighLevelClient> map=new HashMap<>();

    public ESPool() {
        map.put("es",restHighLevelClient("192.168.150.161",9201));
    }
    public RestHighLevelClient getDataSource(String key){
        return map.get(key);
    }
    public RestHighLevelClient restHighLevelClient(String ip, Integer port){
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost(ip,port,"http"))
        );
        return restHighLevelClient;
    }

}
